package com.yuzhihao.writejvm.attributes.runtimeva;

import com.yuzhihao.writejvm.clazz.ClassInfo;
import com.yuzhihao.writejvm.read.Parse;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.log4j.Log4j2;

import java.io.DataInputStream;
import java.io.IOException;

/**
 * 元素值属性
 *
 * @author yzh
 * @since 2021年12月11日14:28:03
 */
@Data
@Log4j2
@EqualsAndHashCode(callSuper = true)
public class EnumConstValue extends ElementValue {

    private int type_name_index_u2 = 2;

    private int type_name_index;

    private int const_name_index_u2 = 2;

    private int const_name_index;

    public EnumConstValue(int tag){
        super();
        super.setTag(tag);
    }

    @Override
    public void parse(DataInputStream dis, ClassInfo ci) {
        try {
            this.type_name_index = Parse.byteToInt(this.type_name_index_u2, dis);
            this.const_name_index = Parse.byteToInt(this.const_name_index_u2, dis);
        } catch (IOException e) {
            log.error(e);
        }
    }

}
